<!DOCTYPE html>
<html lang="en">

<!-- Head -->

<head>

    <title>和学在线网课自助服务</title>

    <!-- Meta-Tags -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <!-- style CSS -->
    <link rel="stylesheet" href="../static/css/style.css" type="text/css" media="all">
    <!-- google fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap" rel="stylesheet">
</head>
<!-- //Head -->
<body>

    <section class="main">
        <div class="logo text-center">
            <h1> <a href="index.html"> 和学在线网课代刷</a></h1>
        </div>
        <div class="content-w3ls text-center">
            <img src="../static/images/admin.png" alt="" class="img-responsive">
            <div>
                <div class="wthree-field">
                    <input name="username" type="text" value="" placeholder="学号" required>
                </div>
                <div class="wthree-field">
                    <button type="submit" class="btn" onclick="submit()">进入</button>
                </div>
                <div class="login-bottom">
                    <a href="/login" class="" target="_parent">登录</a>
                </div>
            </div>
        </div>
        <div class="copyright">
            <p>© 2021 鬼鬼 网站享有最终解释权，使用便默认同意。</p>
        </div>
    </section>

</body>
<script>
    function  submit(){
        let http=new XMLHttpRequest();
        let data=new FormData();
        let username=document.getElementsByName('username')[0].value;
        data.append('username',username);
        http.open("POST",'/getcourse',false);
        http.send(data);
        let rp = JSON.parse(http.responseText);
        document.getElementsByName('username')[0].value="";
        if(String(rp)==="" ){
            window.alert("本学期无课程");
        }else if(typeof rp === "string" ) {
            window.alert(rp);
        }else {
            document.cookie="username="+username;
            location.assign("/background");
        }
    }
</script>
</html>